#include "Indicator.h"

float Indicator::timer_limit = 70;
//-------------------------------------------------------
float Indicator::discharge_speed = 2;
//-------------------------------------------------------
Indicator::Indicator(string name):StaticAnimation(name, 1){
    t.loadFromFile(getFramePath());
    full_charge = t.getSize().x;
    strip_h = t.getSize().y;
    cur_charge = full_charge;
    s.setTexture(t);
    timer = new Clock();
}
//-------------------------------------------------------
void Indicator::animate(float time){
    float epl_time = timer->getElapsedTime().asMilliseconds();
    if( (epl_time >= timer_limit) && (cur_charge > 0) ){
        cur_charge -= discharge_speed;
        timer->restart();
    }
}
//-------------------------------------------------------
Sprite* Indicator::getCurrentFrame(){
    s.setTextureRect( IntRect(0, 0, cur_charge, strip_h));
    return &s;
}
//-------------------------------------------------------
void Indicator::charge(){
    cur_charge = full_charge;
}
//-------------------------------------------------------
bool Indicator::isDischarge(){
    return cur_charge <= 0;
}
